<style>
/*body {
    font-family: "Arial", "Microsoft YaHei";
    margin: 10px;
    font-size: 12px;
    background: #fff;
}

h1 {
    text-align: center;
    font-weight: 400
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th,
td {
    border: 1px solid #333;
    padding: 2px;
    text-align: center;
}

.info {
    margin-top: 20px;
}

p {
    margin: 0;
    line-height: 1.5
}

.item {
    display: flex;
    justify-content: space-between;
}*/

body {
  font-family: "Arial", "Microsoft YaHei";
  margin: 0;
  font-size: 12px;
  background: #fff;
  -webkit-print-color-adjust: exact; /* 保证颜色不丢失 */
}

h1 {
  text-align: center;
  font-weight: 400;
  margin: 0;
  padding: 5px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}

th, td {
  border: 1px solid #333;
  padding: 2px;
  text-align: center;
  word-break: break-all;
}

.p1 {
  justify-content: space-between;
  display: flex;
  width: 100%;
  margin-top: 4px;
  margin-bottom: 2px;
  font-size: 12px;
}

@page {
  size: A4;
  margin: 0; /* 🔥 去掉默认页边距 */
}

@media print {
  html, body {
    width: 210mm;
    height: 297mm;
    margin: 0;
    padding: 0;
    overflow: hidden; /* 🔥 防止内容超出触发分页 */
  }

  .print-page {
    width: 210mm;
    height: 297mm;
    overflow: hidden;
    box-sizing: border-box;
    padding: 10mm 12mm 10mm 12mm;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  table, tr, td, th {
    page-break-inside: avoid;
  }

  * {
    page-break-after: avoid !important;
    page-break-before: avoid !important;
  }
}


</style>
{volist name="grouped" id="item"}
<h1>{$item.gongyingshang.name}销售单</h1>
<div class="p1">
    <div>联系人: {$item.gongyingshang.consignee}</div>
    <div>联系电话: {$item.gongyingshang.phone}</div>
    
  </div>

  <div class="p1">
    <div>客户地址: {$item.gongyingshang.address}</div>
    <div>日期: {$post.start} - {$post.end}</div>
  </div>
 <?php $i=0 ?>
<table>
    <thead>
        <tr>
            <td>序号</td>
            <td>商品名称</td>
            <td>数量</td>
        </tr>
    </thead>
    <tbody>
       
        {volist name="item.goods" id="vo"}
        <tr>
            <td>
                {$i+1}
            </td>
            <td>
                {$vo.goods_name}
            </td>
            <td>
                {$vo.total_num}
            </td>
            <?php $i++ ?>
        </tr>
        
        {/volist}
    </tbody>
</table>
{/volist}
<!-- <script>
    window.onload = function() {
      window.print();
    };
  </script> -->